package org.example.algorithm.array;

/**
 * 遍历解法
 */
public class NumArraySolution {
    private int[] nums;

    public static void main(String[] args) {

    }

    public NumArraySolution(int[] nums) {
        this.nums = nums;
    }


    public int sumRange(int left, int right) {
        if (nums.length == 0) {
            return 0;
        }
        int sum = 0;
        for (int i=left;i<=right;i++) {
            sum += nums[i];
        }
        return sum;
    }
}
